package company.entity;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import sales.entity.SalesInquiry;
import sales.entity.SalesQuotation;

@Entity
public class Company implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    private String name;
    private String address;
    private String email;
    private String contactPersonTitle;
    private String contactPersonName;
    private String contactNumber;
    private String companyType;
    private String companyStatus;// "Full Customer" or "Sales Lead"
    
    @OneToMany(targetEntity=SalesInquiry.class, cascade={CascadeType.PERSIST}, mappedBy="company")
    private List<SalesInquiry> salesInquiries;
    
    @OneToMany(cascade={CascadeType.PERSIST}, mappedBy="company")
    private Collection<SalesQuotation> salesQuotations;
    
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getContactPersonTitle() {
        return contactPersonTitle;
    }

    public void setContactPersonTitle(String contactPersonTitle) {
        this.contactPersonTitle = contactPersonTitle;
    }

    public String getContactPersonName() {
        return contactPersonName;
    }

    public void setContactPersonName(String contactPersonName) {
        this.contactPersonName = contactPersonName;
    }

    public String getContactNumber() {
        return contactNumber;
    }

    public void setContactNumber(String contactNumber) {
        this.contactNumber = contactNumber;
    }

    public String getCompanyType() {
        return companyType;
    }

    public void setCompanyType(String companyType) {
        this.companyType = companyType;
    }

    public String getCompanyStatus() {
        return companyStatus;
    }

    public void setCompanyStatus(String companyStatus) {
        this.companyStatus = companyStatus;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (getId() != null ? getId().hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Company)) {
            return false;
        }
        Company other = (Company) object;
        if ((this.getId() == null && other.getId() != null) || (this.getId() != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entity.company.Company[ id=" + getId() + " ]";
    }

    /**
     * @return the salesInquiries
     */
    public List<SalesInquiry> getSalesInquiries() {
        return salesInquiries;
    }

    /**
     * @param salesInquiries the salesInquiries to set
     */
    public void setSalesInquiries(List<SalesInquiry> salesInquiries) {
        this.salesInquiries = salesInquiries;
    }

    /**
     * @return the salesQuotations
     */
    public Collection<SalesQuotation> getSalesQuotations() {
        return salesQuotations;
    }

    /**
     * @param salesQuotations the salesQuotations to set
     */
    public void setSalesQuotations(Collection<SalesQuotation> salesQuotations) {
        this.salesQuotations = salesQuotations;
    }
}
